package com.isky.visual.db.controller;


import com.isky.visual.db.entity.AdsDatastore;
import com.isky.visual.db.service.IAdsDatastoreService;
import com.isky.visual.result.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 结果集 前端控制器
 * </p>
 *
 * @author wudl
 * @since 2020-04-19
 */
//@RestController
//@RequestMapping("/db/ads-datastore")
//@Api(tags = {"获取数据的"})
public class ADSDatastoreController {


    @Autowired
    IAdsDatastoreService datastoreService;

    @PostMapping(value = "/getReportModel")
    @ApiOperation("获取统计图的接口")
    public ResultVo<Object> getReportModel(@RequestBody  Map<String, String>  dataSourceName) {
        AdsDatastore adsDatastore = new AdsDatastore();
        String dataSourceName1 = dataSourceName.get("dataSourceName");
        adsDatastore.setStatName(dataSourceName1);
        ResultVo<Object> model = datastoreService.getNameByReportModel(adsDatastore);
        return datastoreService.getNameByReportModel(adsDatastore);
    }

    @GetMapping(value = "/getAllReportModel")
    public ResultVo<List<AdsDatastore>> getAllReportModel() {
        List<AdsDatastore> list = datastoreService.list();
        return ResultVo.success(list);
    }


    @PostMapping(value = "/getBarReport")
    @ApiOperation("获取统计图的接口")
    public ResultVo<Object> getBarReport(@RequestBody  Map<String, String>  dataSourceName) {

        return datastoreService.getBarReport();
    }


}
